<?php
declare(strict_types=1);
namespace Field;

class SysPagesConst
{
    public const pk='PageID';
    public const index=['PageID'];
	public const fields=['PageID','ParentPageID','CateID','Pinyin','Title','AttachID','UserID','CreateAt','UpdateAt','Status','IsRecom','Views','Zan','Cai','Rank'];
	public const comment=['PageID'=>'单页ID','ParentPageID'=>'父单页ID','CateID'=>'分类ID','Pinyin'=>'拼音用来伪静态路径','Title'=>'标题','AttachID'=>'附件ID','UserID'=>'会员编号','CreateAt'=>'','UpdateAt'=>'','Status'=>'0-不显示 1-显示','IsRecom'=>'推荐','Views'=>'浏览次数','Zan'=>'','Cai'=>'','Rank'=>''];
	/*
    * @Field PageID
    * @Type int(10) unsigned
    * @Collation 
    * @Null NO
    * @Key PRI
    * @Default 
    * @Extra auto_increment
    * @Privileges select,insert,update,references
    * @Comment 单页ID
    */
    public const PageID = 'PageID';
    /*
    * @Field ParentPageID
    * @Type int(11)
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 父单页ID
    */
    public const ParentPageID = 'ParentPageID';
    /*
    * @Field CateID
    * @Type int(10) unsigned
    * @Collation 
    * @Null NO
    * @Key MUL
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 分类ID
    */
    public const CateID = 'CateID';
    /*
    * @Field Pinyin
    * @Type varchar(32)
    * @Collation utf8mb4_general_ci
    * @Null YES
    * @Key MUL
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 拼音用来伪静态路径
    */
    public const Pinyin = 'Pinyin';
    /*
    * @Field Title
    * @Type varchar(120)
    * @Collation utf8mb4_general_ci
    * @Null YES
    * @Key 
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 标题
    */
    public const Title = 'Title';
    /*
    * @Field AttachID
    * @Type int(10)
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 附件ID
    */
    public const AttachID = 'AttachID';
    /*
    * @Field UserID
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 会员编号
    */
    public const UserID = 'UserID';
    /*
    * @Field CreateAt
    * @Type timestamp
    * @Collation 
    * @Null YES
    * @Key 
    * @Default CURRENT_TIMESTAMP
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const CreateAt = 'CreateAt';
    /*
    * @Field UpdateAt
    * @Type timestamp
    * @Collation 
    * @Null YES
    * @Key 
    * @Default CURRENT_TIMESTAMP
    * @Extra on update CURRENT_TIMESTAMP
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const UpdateAt = 'UpdateAt';
    /*
    * @Field Status
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 0-不显示 1-显示
    */
    public const Status = 'Status';
    /*
    * @Field IsRecom
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 推荐
    */
    public const IsRecom = 'IsRecom';
    /*
    * @Field Views
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 浏览次数
    */
    public const Views = 'Views';
    /*
    * @Field Zan
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const Zan = 'Zan';
    /*
    * @Field Cai
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const Cai = 'Cai';
    /*
    * @Field Rank
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const Rank = 'Rank';
}

class SysPagesColumns
{
public  int $PageID;
   public  int $ParentPageID=0;
   public  int $CateID;
   public  ?string $Pinyin='';
   public  ?string $Title='';
   public  int $AttachID=0;
   public  int $UserID=0;
   public  ?string $CreateAt='';
   public  ?string $UpdateAt='';
   public  int $Status=0;
   public  int $IsRecom=0;
   public  int $Views=0;
   public  int $Zan=0;
   public  int $Cai=0;
   public  int $Rank=0;
	public function toArray():array
	{
		return [
'PageID'=>$this->PageID,
    'ParentPageID'=>$this->ParentPageID,
    'CateID'=>$this->CateID,
    'Pinyin'=>$this->Pinyin,
    'Title'=>$this->Title,
    'AttachID'=>$this->AttachID,
    'UserID'=>$this->UserID,
    'CreateAt'=>$this->CreateAt,
    'UpdateAt'=>$this->UpdateAt,
    'Status'=>$this->Status,
    'IsRecom'=>$this->IsRecom,
    'Views'=>$this->Views,
    'Zan'=>$this->Zan,
    'Cai'=>$this->Cai,
    'Rank'=>$this->Rank,        ];
	}
}

class SysPagesRow
{
	public SysPagesColumns $data;
	public function toArray():array
	{
		return $this->data->toArray();
    }

    public function getValue(string $field):string|int|null
    {
        return match ($field){
        'PageID' => $this->data->PageID,
        'ParentPageID' => $this->data->ParentPageID,
        'CateID' => $this->data->CateID,
        'Pinyin' => $this->data->Pinyin,
        'Title' => $this->data->Title,
        'AttachID' => $this->data->AttachID,
        'UserID' => $this->data->UserID,
        'CreateAt' => $this->data->CreateAt,
        'UpdateAt' => $this->data->UpdateAt,
        'Status' => $this->data->Status,
        'IsRecom' => $this->data->IsRecom,
        'Views' => $this->data->Views,
        'Zan' => $this->data->Zan,
        'Cai' => $this->data->Cai,
        'Rank' => $this->data->Rank, default=>null
        };
    }

    public function __construct(array $data)
    {
        $this->data = new SysPagesColumns();
        isset($data['PageID']) && $this->data->PageID = (int)$data['PageID'];
           isset($data['ParentPageID']) && $this->data->ParentPageID = (int)$data['ParentPageID'];
           isset($data['CateID']) && $this->data->CateID = (int)$data['CateID'];
           isset($data['Pinyin']) && $this->data->Pinyin = (string)$data['Pinyin'];
           isset($data['Title']) && $this->data->Title = (string)$data['Title'];
           isset($data['AttachID']) && $this->data->AttachID = (int)$data['AttachID'];
           isset($data['UserID']) && $this->data->UserID = (int)$data['UserID'];
           isset($data['CreateAt']) && $this->data->CreateAt = (string)$data['CreateAt'];
           isset($data['UpdateAt']) && $this->data->UpdateAt = (string)$data['UpdateAt'];
           isset($data['Status']) && $this->data->Status = (int)$data['Status'];
           isset($data['IsRecom']) && $this->data->IsRecom = (int)$data['IsRecom'];
           isset($data['Views']) && $this->data->Views = (int)$data['Views'];
           isset($data['Zan']) && $this->data->Zan = (int)$data['Zan'];
           isset($data['Cai']) && $this->data->Cai = (int)$data['Cai'];
           isset($data['Rank']) && $this->data->Rank = (int)$data['Rank'];
    }
}
?>